namespace QMVnSoft.Invoices
{
    using QMVnSoft;
    using QMVnSoft.Controls;
    using System;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Windows.Forms;

    public class FormInvoiceUsed : FormControl
    {
        private DataGridViewTextBoxColumn Column1;
        private DataGridViewTextBoxColumn Column2;
        private DataGridViewTextBoxColumn Column3;
        private DataGridViewTextBoxColumn Column4;
        private DataGridViewTextBoxColumn Column5;
        private IContainer components;
        private GridControl gridControl;
        private DataTable oNotDeleteDataTable;

        public FormInvoiceUsed(string ps_WarningMessage, DataTable po_NotDeleteDataTable)
        {
            this.InitializeComponent();
            this.WarningMessage = ps_WarningMessage;
            this.NotDeleteDataTable = po_NotDeleteDataTable;
            if (AppInstance.Bilingual != 1)
            {
                this.gridControl.Columns[4].Visible = false;
            }
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            this.gridControl = new GridControl();
            this.Column4 = new DataGridViewTextBoxColumn();
            this.Column1 = new DataGridViewTextBoxColumn();
            this.Column2 = new DataGridViewTextBoxColumn();
            this.Column3 = new DataGridViewTextBoxColumn();
            this.Column5 = new DataGridViewTextBoxColumn();
            ((ISupportInitialize) this.gridControl).BeginInit();
            base.SuspendLayout();
            this.gridControl.AllowUserToAddRows = false;
            this.gridControl.AllowUserToDeleteRows = false;
            this.gridControl.CheckAutoSize = true;
            this.gridControl.CheckColor = false;
            this.gridControl.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            this.gridControl.Columns.AddRange(new DataGridViewColumn[] { this.Column4, this.Column1, this.Column2, this.Column3, this.Column5 });
            this.gridControl.Dock = DockStyle.Fill;
            this.gridControl.Font = new Font("Arial", 8.25f);
            this.gridControl.Location = new Point(0, 0);
            this.gridControl.Name = "gridControl";
            this.gridControl.ReadOnly = true;
            this.gridControl.Size = new Size(0x268, 0x175);
            this.gridControl.TabIndex = 0;
            this.Column4.DataPropertyName = "Ma_Ct";
            this.Column4.HeaderText = "Ctừ";
            this.Column4.Name = "Column4";
            this.Column4.ReadOnly = true;
            this.Column4.Resizable = DataGridViewTriState.False;
            this.Column4.Width = 40;
            this.Column1.DataPropertyName = "Ngay_Ct";
            this.Column1.HeaderText = "Ngày";
            this.Column1.Name = "Column1";
            this.Column1.ReadOnly = true;
            this.Column1.Resizable = DataGridViewTriState.False;
            this.Column1.Width = 0x3e;
            this.Column2.DataPropertyName = "So_Ct";
            this.Column2.HeaderText = "Số";
            this.Column2.Name = "Column2";
            this.Column2.ReadOnly = true;
            this.Column2.Width = 70;
            this.Column3.DataPropertyName = "Dien_Giai";
            this.Column3.HeaderText = "Diễn giải (VN)";
            this.Column3.Name = "Column3";
            this.Column3.ReadOnly = true;
            this.Column3.Width = 0xc9;
            this.Column5.DataPropertyName = "Desc_EN";
            this.Column5.HeaderText = "Diễn giải (EN)";
            this.Column5.Name = "Column5";
            this.Column5.ReadOnly = true;
            this.Column5.Width = 200;
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.ClientSize = new Size(0x268, 0x175);
            base.Controls.Add(this.gridControl);
            //base.FormBorderStyle = FormBorderStyle.FixedSingle;
            base.MaximizeBox = false;
            base.MinimizeBox = false;
            base.Name = "FormInvoiceUsed";
            ((ISupportInitialize) this.gridControl).EndInit();
            base.ResumeLayout(false);
        }

        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            if (keyData == Keys.Escape)
            {
                base.Close();
                return false;
            }
            return base.ProcessCmdKey(ref msg, keyData);
        }

        public DataTable NotDeleteDataTable
        {
            set
            {
                this.oNotDeleteDataTable = value;
                this.gridControl.AutoGenerateColumns = false;
                this.gridControl.DataSource = new BindingSource(this.oNotDeleteDataTable, this.oNotDeleteDataTable.TableName);
                ((BindingSource) this.gridControl.DataSource).Sort = "Ngay_Ct, So_Ct";
            }
        }

        public string WarningMessage
        {
            set
            {
                this.Text = value;
            }
        }
    }
}

